package de.rosstauscher.jculfw.fs20;

/**********************************************************
 * An enumeration for all the commands that you can send to an
 * FS20 device.
 * 
 * @author Rossi java@rosstauscher.de
 *********************************************************/

public enum FS20CommandCode {
	ON("11"),
	OFF("00"),
	TOGGLE("12"),
	RESET("1b"),
	
	DIM_UP("13"),
	DIM_DOWN("14"),
	DIM_UP_DOWN("15"),
	DIM_06("01"),
	DIM_12("02"),
	DIM_18("03"),
	DIM_25("04"),
	DIM_31("05"),
	DIM_37("06"),
	DIM_43("07"),
	DIM_50("08"),
	DIM_56("09"),
	DIM_62("0a"),
	DIM_68("0b"),
	DIM_75("0c"),
	DIM_81("0d"),
	DIM_87("0e"),
	DIM_93("0f"),
	DIM_100("10"),
	
	SET_TIMER("16"),
	GET_STATE("17"),
	
	UNKNOWN("XX"),
	;
		
//Some more seem in the fhem fs20 module.		
//		  "18" => "off-for-timer",
//		  "19" => "on-for-timer",
//		  "1a" => "on-old-for-timer",
//		  "1c" => "ramp-on-time",      #time to reach the desired dim value on dimmers
//		  "1d" => "ramp-off-time",     #time to reach the off state on dimmers
//		  "1e" => "on-old-for-timer-prev", # old val for timer, then go to prev. state
//		  "1f" => "on-100-for-timer-prev", # 100% for timer, then go to previous state
		
	final String hexCode;
				  
	/**********************************************************
	 * Constructor
	 * @param hexCode of the command.
	 *********************************************************/
	  
	private FS20CommandCode(String hexCode) {
		this.hexCode = hexCode;
	}
	
	/**********************************************************
	 * @return the command hex code.
	 *********************************************************/
	
	public String toHex() {
		return this.hexCode;
	}
	
	/**********************************************************
	 * Parse a hex code into a FS20CommandCode object.
	 * @param hexCode to parse.
	 * @return a FS20CommandCode, UNKNOWN if not parseable.
	 *********************************************************/
	
	public static FS20CommandCode fromHex(String hexCode) {
		for (FS20CommandCode code : values()) {
			if (code.toHex().equalsIgnoreCase(hexCode)) {
				return code;
			}
		}
		return UNKNOWN;
	}
		
}
